#! python3

import os
import sys
import chardet

g_folder = ""

g_curFolder = sys.path[0]+"\\"

g_source = g_curFolder + "机锋论坛-479万-自营.txt"
g_target = g_curFolder + "jifeng_r.txt"
g_error = g_curFolder + "jifeng_e.txt"

def CheckCopy():
    iii = 1
    print("***start")
    
    with open(g_error,'w', encoding='utf8') as fe:
        with open(g_target,'w', encoding='utf8') as fr:
            with open(g_source, "r+", encoding="utf-8",errors='ignore') as f :
                for l in f.readlines():
                    iii = iii + 1
        #            if iii > 10000:
        #                break

                    if("@" in l or iii == 1):
                        t = l.replace("~|^",",").replace("~",",")
                        if(t.count(",") > 3):
                            fe.write(t)
                            continue
                        fr.write(t)
        #               fr.write('\n')
                        print(iii)
             
    
    print("***done")

CheckCopy()
